/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * produto_busca.java
 *
 * Created on 05/06/2011, 14:50:58
 */
package Visualização;

import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Pedro
 */
public class produto_busca extends javax.swing.JFrame {
    
    public produto_busca() {
        initComponents();
        this.setLocationRelativeTo(null);
        int i;
        pesoInput.setEditable(false);
        quantidadeInput.setEditable(false);
        corSelect.setEnabled(false);
        tabelaShow.getColumnModel().getColumn(0).setPreferredWidth(30);
        tabelaShow.getColumnModel().getColumn(1).setPreferredWidth(150);
        tabelaShow.getColumnModel().getColumn(2).setPreferredWidth(40);
        DefaultTableModel modelo = (DefaultTableModel)tabelaShow.getModel();
        modelo.setNumRows(0); 
        for(i=0;i<7;i++)
            modelo.addRow(new Object [] {"","",""});
        String[] c = new String[50];
        
        BO.produtoBO pBO = new BO.produtoBO();
        Negocio.produto combo = new Negocio.produto();
        
        combo.PreencherCombo(pBO);
        classificacaoSelect.removeAllItems();
        classificacaoSelect.addItem("        ");
        c=pBO.getVet();
        for(i=0;i<pBO.getTamVet();i++)
            classificacaoSelect.addItem(c[i]);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        codigoLabel = new javax.swing.JLabel();
        idInput = new javax.swing.JTextField();
        classificacaoSelect = new javax.swing.JComboBox();
        nomeInput = new javax.swing.JTextField();
        classificacaoLabel = new javax.swing.JLabel();
        nomeLabel = new javax.swing.JLabel();
        usuariosTable = new javax.swing.JScrollPane();
        tabelaShow = new javax.swing.JTable();
        buscarButton = new javax.swing.JButton();
        selecionarButton = new javax.swing.JButton();
        excluirButton = new javax.swing.JButton();
        tituloLabel = new javax.swing.JLabel();
        corLabel = new javax.swing.JLabel();
        corSelect = new javax.swing.JComboBox();
        pesoLabel = new javax.swing.JLabel();
        pesoInput = new javax.swing.JTextField();
        quantidadeInput = new javax.swing.JTextField();
        quantidadeLabel = new javax.swing.JLabel();
        limparButton = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        codigoLabel.setText("Código:");

        idInput.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                idInputActionPerformed(evt);
            }
        });

        classificacaoSelect.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "          ", "Item 1", "Item 2", "Item 3", "Item 4" }));

        nomeInput.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nomeInputActionPerformed(evt);
            }
        });

        classificacaoLabel.setText("Classificação:");

        nomeLabel.setText("Nome:");

        tabelaShow.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "ID", "Nome", "Cor"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabelaShow.setCellEditor(null);
        tabelaShow.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabelaShowMouseClicked(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                tabelaShowMousePressed(evt);
            }
        });
        tabelaShow.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tabelaShowKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tabelaShowKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tabelaShowKeyTyped(evt);
            }
        });
        usuariosTable.setViewportView(tabelaShow);

        buscarButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Buscar.png"))); // NOI18N
        buscarButton.setText("Buscar");
        buscarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarButtonActionPerformed(evt);
            }
        });

        selecionarButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Escolher.png"))); // NOI18N
        selecionarButton.setText("Alterar");
        selecionarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                selecionarButtonActionPerformed(evt);
            }
        });

        excluirButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Lixeira.png"))); // NOI18N
        excluirButton.setText("Excluir");
        excluirButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                excluirButtonActionPerformed(evt);
            }
        });

        tituloLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        tituloLabel.setText("Buscar Produto");

        corLabel.setText("Cor:");

        corSelect.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "           ", "alumínio", "amarelo", "argila", "azul", "branco", "cerejeira", "cinza", "grafite", "marfim", "marrom", "mogno", "metálico", "preto", "rosa", "tabaco", "verde", "vermelho", "violeta" }));

        pesoLabel.setText("Peso:");

        quantidadeLabel.setText("Quantidade:");

        limparButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Limpar.png"))); // NOI18N
        limparButton.setText("Limpar Campos");
        limparButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                limparButtonActionPerformed(evt);
            }
        });

        jLabel1.setText("Kg.");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(usuariosTable, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)
                    .addComponent(tituloLabel)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(buscarButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(limparButton, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(nomeLabel)
                            .addComponent(codigoLabel)
                            .addComponent(classificacaoLabel)
                            .addComponent(corLabel)
                            .addComponent(quantidadeLabel)
                            .addComponent(pesoLabel))
                        .addGap(16, 16, 16)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(corSelect, 0, 174, Short.MAX_VALUE)
                            .addComponent(quantidadeInput, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
                            .addComponent(classificacaoSelect, 0, 174, Short.MAX_VALUE)
                            .addComponent(nomeInput, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
                            .addComponent(idInput, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(pesoInput, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel1))))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(selecionarButton, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(excluirButton, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tituloLabel)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(idInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(codigoLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nomeInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(nomeLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(classificacaoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(classificacaoSelect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(corLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(corSelect, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(quantidadeInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(quantidadeLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pesoInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pesoLabel)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buscarButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(limparButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(usuariosTable, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(selecionarButton)
                    .addComponent(excluirButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buscarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarButtonActionPerformed
        buscar();
}//GEN-LAST:event_buscarButtonActionPerformed

    private void excluirButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_excluirButtonActionPerformed
        int linha, id, op, i;
        op = JOptionPane.showConfirmDialog(null, "Deseja excluir a linha selecionada?", "Excluir", JOptionPane.YES_NO_OPTION);
        if(op==JOptionPane.YES_OPTION)
        {
            String codigo;
            BO.produtoBO pBO;
            Negocio.produto p;

            pBO = new BO.produtoBO();
            linha = tabelaShow.getSelectedRow();
            codigo = tabelaShow.getValueAt(linha, 0).toString();
            pBO.setIdBO(Integer.parseInt(codigo));
            pBO.setNomeBO(tabelaShow.getValueAt(linha, 1).toString());

            p = new Negocio.produto();
            p.Excluir(pBO);
            
            limpar();
            tabelaShow.getColumnModel().getColumn(0).setPreferredWidth(30);
            tabelaShow.getColumnModel().getColumn(1).setPreferredWidth(150);
            tabelaShow.getColumnModel().getColumn(2).setPreferredWidth(40);
            DefaultTableModel modelo = (DefaultTableModel)tabelaShow.getModel();
            modelo.setNumRows(0); 
            for(i=0;i<3;i++)
                modelo.addRow(new Object [] {"","",""}); 
            tabelaShow.isEditing();
        }

}//GEN-LAST:event_excluirButtonActionPerformed

    private void tabelaShowMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelaShowMouseClicked
        if (tabelaShow.getValueAt(0, 0).equals(""))
        {
            return;
        }
        else
        {
            String aux;
            int quantidade, linha, id;
            float peso;

            BO.produtoBO pBO;
            Negocio.produto p;

            linha = tabelaShow.getSelectedRow();
            id = Integer.parseInt(tabelaShow.getValueAt(linha, 0).toString());

            pBO = new BO.produtoBO();
            pBO.setIdBO(id);

            p = new Negocio.produto();
            p.BuscarPorCodigo(pBO);

            aux = String.valueOf(pBO.getIdBO());
            this.idInput.setText(aux);
            this.nomeInput.setText(pBO.getNomeBO());
            aux = String.valueOf(pBO.getQuantidadeBO());
            this.quantidadeInput.setText(aux);
            this.classificacaoSelect.setSelectedItem(pBO.getCategoriaBO());
            this.corSelect.setSelectedItem(pBO.getCorBO());
            aux = String.valueOf(pBO.getPesoBO());
            this.pesoInput.setText(aux);
        }
    }//GEN-LAST:event_tabelaShowMouseClicked

    private void selecionarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selecionarButtonActionPerformed
        int linha, id;
        
        BO.produtoBO pBO;
        pBO = new BO.produtoBO();
        
        linha = tabelaShow.getSelectedRow();
        id = Integer.parseInt(tabelaShow.getValueAt(linha, 0).toString());
        pBO.setIdBO(id);
        
        new produto_alteracao(pBO).show();
    }//GEN-LAST:event_selecionarButtonActionPerformed

    private void idInputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idInputActionPerformed
        buscar();
    }//GEN-LAST:event_idInputActionPerformed

    private void nomeInputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nomeInputActionPerformed
        buscar();
    }//GEN-LAST:event_nomeInputActionPerformed

    private void tabelaShowMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelaShowMousePressed
        tabelaShowMouseClicked(evt);
    }//GEN-LAST:event_tabelaShowMousePressed

    private void limparButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_limparButtonActionPerformed
        int i;
        this.idInput.setText("");
        this.nomeInput.setText("");
        this.pesoInput.setText("");
        this.classificacaoSelect.setSelectedIndex(0);
        this.corSelect.setSelectedIndex(0);
        this.quantidadeInput.setText("");
        tabelaShow.getColumnModel().getColumn(0).setPreferredWidth(30);
        tabelaShow.getColumnModel().getColumn(1).setPreferredWidth(150);
        tabelaShow.getColumnModel().getColumn(2).setPreferredWidth(30);
        DefaultTableModel modelo = (DefaultTableModel)tabelaShow.getModel();
        modelo.setNumRows(0); 
        for(i=0;i<3;i++)
            modelo.addRow(new Object [] {"","",""});
    }//GEN-LAST:event_limparButtonActionPerformed

    private void tabelaShowKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tabelaShowKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) 
        {
            selecionarButtonActionPerformed(null);
        }
        else
        {
            tabelaShowMousePressed(null);
        }
    }//GEN-LAST:event_tabelaShowKeyPressed

    private void tabelaShowKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tabelaShowKeyTyped
        tabelaShowMousePressed(null);
    }//GEN-LAST:event_tabelaShowKeyTyped

    private void tabelaShowKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tabelaShowKeyReleased
        tabelaShowMousePressed(null);
    }//GEN-LAST:event_tabelaShowKeyReleased

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new produto_busca().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buscarButton;
    private javax.swing.JLabel classificacaoLabel;
    private javax.swing.JComboBox classificacaoSelect;
    private javax.swing.JLabel codigoLabel;
    private javax.swing.JLabel corLabel;
    private javax.swing.JComboBox corSelect;
    private javax.swing.JButton excluirButton;
    private javax.swing.JTextField idInput;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JButton limparButton;
    private javax.swing.JTextField nomeInput;
    private javax.swing.JLabel nomeLabel;
    private javax.swing.JTextField pesoInput;
    private javax.swing.JLabel pesoLabel;
    private javax.swing.JTextField quantidadeInput;
    private javax.swing.JLabel quantidadeLabel;
    private javax.swing.JButton selecionarButton;
    private javax.swing.JTable tabelaShow;
    private javax.swing.JLabel tituloLabel;
    private javax.swing.JScrollPane usuariosTable;
    // End of variables declaration//GEN-END:variables
    public void limpar()
    {
        idInput.setText("");
        nomeInput.setText("");
        quantidadeInput.setText("");
        pesoInput.setText("");
        classificacaoSelect.setSelectedIndex(0);
        corSelect.setSelectedIndex(0);
    }
    
    public void buscar()
    {
        String aux;
        int id, quantidade, classel;
        classel = classificacaoSelect.getSelectedIndex();
        float peso;
        BO.produtoBO pBO;
        Negocio.produto p;
        
        
        if(!nomeInput.getText().equals(""))
        {
            int tam, i, j=0;
            String matriz[][] = new String[500][3];
            pBO = new BO.produtoBO();
            pBO.setNomeBO(this.nomeInput.getText());

            p = new Negocio.produto();
            p.BuscarPorNome(pBO);

            id=pBO.getIdBO();
            if(id!=0)
            {
                aux = String.valueOf(id);
                this.idInput.setText(aux);
                quantidade=pBO.getQuantidadeBO();
                aux = String.valueOf(quantidade);
                this.quantidadeInput.setText(aux);
                this.classificacaoSelect.setSelectedItem(pBO.getCategoriaBO());
                this.corSelect.setSelectedItem(pBO.getCorBO());
                aux = String.valueOf(pBO.getPesoBO());
                this.pesoInput.setText(aux);
                tam = pBO.getTam();
                matriz = pBO.getMat();
                tabelaShow.getColumnModel().getColumn(0).setPreferredWidth(30);
                tabelaShow.getColumnModel().getColumn(1).setPreferredWidth(150);
                tabelaShow.getColumnModel().getColumn(2).setPreferredWidth(40);
                DefaultTableModel modelo = (DefaultTableModel)tabelaShow.getModel();
                modelo.setNumRows(0);
                for(i=0;i<tam;i++)
                    modelo.addRow(new Object [] {matriz[i][j],matriz[i][j+1],matriz[i][j+2]});
            }
            else
            {
                limpar();
                nomeInput.setText(pBO.getNomeBO());
                JOptionPane.showMessageDialog(null, "Não há produto com estes valores");
            }
        }
        else if(!idInput.getText().equals(""))
        {
            aux = idInput.getText();
            id = Integer.parseInt(aux);
            pBO = new BO.produtoBO();
            pBO.setIdBO(id);

            p = new Negocio.produto();
            p.BuscarPorCodigo(pBO);

            if(pBO.getNomeBO().equals(""))
            {
                id = pBO.getIdBO();
                limpar();
                idInput.setText(aux);
                JOptionPane.showMessageDialog(null, "Não há produto com estes valores");
            }
            else
            {
                this.nomeInput.setText(pBO.getNomeBO());
                quantidade=pBO.getQuantidadeBO();
                aux = String.valueOf(quantidade);
                this.quantidadeInput.setText(aux);
                this.classificacaoSelect.setSelectedItem(pBO.getCategoriaBO());
                this.corSelect.setSelectedItem(pBO.getCorBO());
                aux = String.valueOf(pBO.getPesoBO());
                this.pesoInput.setText(aux);
                tabelaShow.getColumnModel().getColumn(0).setPreferredWidth(30);
                tabelaShow.getColumnModel().getColumn(1).setPreferredWidth(150);
                tabelaShow.getColumnModel().getColumn(2).setPreferredWidth(40);
                DefaultTableModel modelo = (DefaultTableModel)tabelaShow.getModel();
                modelo.setNumRows(0);
                    modelo.addRow(new Object [] {pBO.getIdBO(),pBO.getNomeBO(),pBO.getQuantidadeBO()});
            }
        }
        else if(classel!=0)
        {
            int i, j=0, tam;
            String matriz[][] = new String[500][3];
            pBO = new BO.produtoBO();
            pBO.setCategoriaBO((String)classificacaoSelect.getSelectedItem());
            p = new Negocio.produto();
            p.BuscarPorCategoria(pBO);

            id=pBO.getIdBO();
            if(id!=0)
            {
                aux = String.valueOf(id);
                this.idInput.setText(aux);
                this.nomeInput.setText(pBO.getNomeBO());
                quantidade=pBO.getQuantidadeBO();
                aux = String.valueOf(quantidade);
                this.quantidadeInput.setText(aux);
                this.corSelect.setSelectedItem(pBO.getCorBO());
                aux = String.valueOf(pBO.getPesoBO());
                this.pesoInput.setText(aux);
                tam = pBO.getTam();
                matriz = pBO.getMat();
                tabelaShow.getColumnModel().getColumn(0).setPreferredWidth(30);
                tabelaShow.getColumnModel().getColumn(1).setPreferredWidth(150);
                tabelaShow.getColumnModel().getColumn(2).setPreferredWidth(40);
                DefaultTableModel modelo = (DefaultTableModel)tabelaShow.getModel();
                modelo.setNumRows(0);
                for(i=0;i<tam;i++)
                    modelo.addRow(new Object [] {matriz[i][j],matriz[i][j+1],matriz[i][j+2]});    
            }
            else
            {
                limpar();
                classificacaoSelect.setSelectedItem(pBO.getCategoriaBO());
                JOptionPane.showMessageDialog(null, "Não há produto com estes valores");
            }
        }
        else
        {
            int i;
            JOptionPane.showMessageDialog(null, "Preencha pelo menos um campo para efetuar a pesquisa!");
            tabelaShow.getColumnModel().getColumn(0).setPreferredWidth(30);
            tabelaShow.getColumnModel().getColumn(1).setPreferredWidth(150);
            tabelaShow.getColumnModel().getColumn(2).setPreferredWidth(30);
            DefaultTableModel modelo = (DefaultTableModel)tabelaShow.getModel();
            modelo.setNumRows(0);
            for(i=0;i<3;i++)
                modelo.addRow(new Object [] {"","",""}); 
            tabelaShow.isEditing();
        }
    }  
}
